{% extends "geonode_base.html" %}

{% load i18n %}
{% load avatar_tags %}

{% block title %}{{ thread.subject }} — {{ block.super }}{% endblock %}

{% block body %}
<h3>{{ thread.subject }}</h3>
<div>
    <b>{% trans "Sent to" %}:</b>
        {% for user in thread.single_users.all%}
            {% if user.username != request.user.username %}
                <a href={{  user.get_absolute_url }}>{{ user.full_name_or_nick }}</a>
                {%if not forloop.last%},{%endif%}
            {% endif %}
        {% endfor %}
        {% if thread.registered_groups.all %}
            ,
        {% endif %}
        {% for group in thread.registered_groups.all%}
            <a href={{  group.groupprofile.get_absolute_url }}>{{ group.groupprofile.title }}</a>
            {%if not forloop.last%},{%endif%}
        {% endfor %}
</div>
<hr />
{% for message in thread.messages.all %}
  <div class="well">
    {% autoescape off %}{% avatar message.sender 50 %}{% endautoescape %}
    {{ message.sent_at }} {% trans "by" %} {% ifequal request.user message.sender %}{% trans "me" %}{% else %}<a href="{{ message.sender.get_absolute_url }}">{{ message.sender }}</a>{% endifequal %}
    <p>{{ message.content }}</p>
  </div>
  {% empty %}
  {% trans "You have no messages" %}.
{% endfor %}
<div>
  <form action="{{ thread.get_absolute_url }}" method="post">
    {% csrf_token %}
    <fieldset>
      <textarea name="content"></textarea>
    </fieldset>
    <input type="submit" value="{% trans "Send Reply" %}" class="btn btn-primary" type="button"/>
  </form>
</div>
{% endblock %}

{% block sidebar %}
<a href="{% url "messages_inbox" %}" class="btn btn-primary" type="button">{% trans "Back to Inbox" %}</a>
{% endblock %}
